Skip to content

列出已加载模型 - YoloListModels

函数简介

返回当前实例已加载的全部模型信息(JSON 数组)。

接口名称

YoloListModels

DLL 调用

long YoloListModels(long ola);

参数说明

参数名类型说明
ola长整数型OLAPlug 对象指针,由 CreateCOLAPlugInterFace 生成。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
// 列出当前已加载的模型
auto models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等
csharp
using OLAPlug;

var ola = new OLAPlugServer();
// 列出当前已加载的模型
var models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
# 列出当前已加载的模型
models = ola.YoloListModels()
# 遍历 models 查看 ModelHandle、TaskType 等
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
// 列出当前已加载的模型
var models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等
cpp
var ola = com("OlaPlug.OlaSoft")
// 列出当前已加载的模型
var models = ola.YoloListModels()
// 遍历 models 查看 ModelHandle、TaskType 等
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
' 列出当前已加载的模型
models = ola.YoloListModels()
' 遍历 models 查看 ModelHandle、TaskType 等
text
.局部变量 ola, OLAPlug
ola.创建 ()
' 列出当前已加载的模型
models = ola.YoloListModels()
' 遍历 models 查看 ModelHandle、TaskType 等
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
// 列出当前已加载的模型
var models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
// 列出当前已加载的模型
自动 models = ola.YoloListModels()
// 遍历 models 查看 ModelHandle、TaskType 等
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
// 列出当前已加载的模型
auto models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long modelsJsonPtr = YoloListModels(instance);
if (modelsJsonPtr != 0) {
    char modelsJson[512] = {0};
    GetStringFromPtr(modelsJsonPtr, modelsJson, sizeof(modelsJson));
    FreeStringPtr(modelsJsonPtr);
}
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();

long instance = CreateCOLAPlugInterFace();
long modelsJsonPtr = YoloListModels(instance);
if (modelsJsonPtr != 0) {
    StringBuilder modelsJson = new StringBuilder(GetStringSize(modelsJsonPtr) + 1);
    GetStringFromPtr(modelsJsonPtr, modelsJson, modelsJson.Capacity);
    FreeStringPtr(modelsJsonPtr);
    string modelsJsonStr = modelsJson.ToString();
}
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
modelsJsonPtr = YoloListModels(instance)
if modelsJsonPtr:
    buf = create_string_buffer(512)
    ola.GetStringFromPtr(modelsJsonPtr, buf, 512)
    ola.FreeStringPtr(modelsJsonPtr)
    modelsJson = buf.value.decode("utf-8")

返回值

长整数型:JSON 字符串指针;数组元素字段同 YoloGetModelInfo。

注意事项